import { createApp } from 'vue'
import { createPinia } from 'pinia'
import mitt from 'mitt'

import App from './App.vue'
import router from './router'
import component from './components'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import "@/assets/css/reset.scss";
import './permission'
import FormCreate from '@form-create/element-ui'
const app = createApp(App)
export const pinia = createPinia()
const Mit = mitt()

app.config.globalProperties.$Bus = Mit
app.use(ElementPlus)
app.use(FormCreate)

for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
// TypeScript注册
// 由于必须要拓展ComponentCustomProperties类型才能获得类型提示
// 每次添加全局函数/变量时，都要在这里拓展
declare module 'vue' {
  export interface ComponentCustomProperties {
    $Bus: typeof Mit
  }
}
app.use(pinia)
app.use(router)
app.use(component)
app.mount('#app')
